package dao;

import java.util.List;

import org.hibernate.Session;

import beans.User;
import util.HibernateManager;

/**
 * 用户数据操作类
 * 
 * @author a9296
 *
 */
public class UserDAO {
	Session session = null;

	public UserDAO() {
		session = HibernateManager.getSession();
	}

	/**
	 * 获取用户信息
	 * 
	 * @param username
	 *            用户名
	 * @param password
	 *            密码
	 * @return
	 */
	public User getUser(String username, String password) {
		User user = null;
		String hql = "from User where username=? and password=?";
		List<User> list = session.createQuery(hql).setString(0, username).setString(1, password).list();
		if (list.size() == 0)
			return null;
		return list.get(0);
	}
}
